package gpl.scotlandyard.ui.tools;

import gpl.scotlandyard.utils.I18n;

import java.awt.Component;

import javax.swing.JOptionPane;

/**
 * Offers JOptionPane shortcuts.
 * @author Norbert Martin
 */
public abstract class JDialogs {

  /** Shows error message.
   * @param parent
   * @param message
   */
  public static void showError(Component parent, String message) {
    JOptionPane.showMessageDialog(parent, message, I18n.get("ERR_SY"), JOptionPane.ERROR_MESSAGE);
  }

  /** Shows info message.
   * @param parent
   * @param message
   */
  public static void showInfo(Component parent, String message) {
    JOptionPane.showMessageDialog(parent, message, I18n.get("MSG_SY"), JOptionPane.INFORMATION_MESSAGE);

  }

  /** Shows multiple input choices.
   * @param parent
   * @param message
   * @param values
   * @param initValue
   * @return answer or null if closed or cancel
   */
  public static Object showInputChoices(Component parent, String message, Object[] values, Object initValue) {
    return JOptionPane.showInputDialog(null, message, I18n.get("MSG_SY"), JOptionPane.QUESTION_MESSAGE, null, values, initValue);
  }

  /** Shows free input.
   * @param parent
   * @param message 
   * @return answer or null if closed or cancel
   */
  public static String showInput(Component parent, String message) {
    return JOptionPane.showInputDialog(parent, message, I18n.get("MSG_SY"), JOptionPane.QUESTION_MESSAGE);
  }

}
